package Reflect;

import java.util.Scanner;

/**
 *   类对象.newInstance()   方法创建实例对象必须使用无参构造器
 */
public class ReflectDemo2 {

    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {

        Person person = new Person();
        System.out.println(person);

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入类名：");
        Class<?> aClass = Class.forName(scanner.nextLine());

        Student student = (Student) aClass.newInstance();
        student.study();
        student.playGame();


    }

}
